/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gerenciadorprojetos.services;

import gerenciadorprojetos.exception.StatusServiceException;
import gerenciadorprojetos.dao.hibernate.StatusTarefaDAO;
import gerenciadorprojetos.dao.StatusTarefa;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

/**
 *
 * @author eduardo
 */
public class StatusService {
    
    private StatusTarefaDAO sDAO;
    
    public List<String> getAllStatus() {
        List<String> saida = new LinkedList<String>();
        
        List<StatusTarefa> s = getsDAO().obterStatus();
        ListIterator<StatusTarefa> it = s.listIterator();
            
        do {
            saida.add(it.next().getDescStatusTarefa());
        } while (it.hasNext());
        
        return saida;
    }
    
    public int getIdStatus(String s) {
        StatusTarefa st = sDAO.obterStatusPorDescricao(s);
        
        if (st != null) {
            return st.getIdStatusTarefa();
        } else {
            throw new StatusServiceException(StatusServiceException.GET_ID_STATUS);
        }
    }

    public StatusTarefaDAO getsDAO() {
        return sDAO;
    }

    public void setsDAO(StatusTarefaDAO sDAO) {
        this.sDAO = sDAO;
    }

}
